package threadPoolTest;

import java.util.concurrent.*;

/**
 * @program: javase
 * @description:
 * @author: lld
 * @create: 2021-04-18 23:00
 **/
public class Demo2 {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                3, 10, 1,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(5),
                Executors.defaultThreadFactory(),
//                new ThreadPoolExecutor.AbortPolicy()
                new ThreadPoolExecutor.CallerRunsPolicy()
        );

        for (int i = 0; i < 20; i++) {
            executor.execute(new Thread(()->{
                System.out.println(Thread.currentThread().getName()+".....");
            }));

        }
        executor.shutdown();
    }
}
